package com.gis507.test.AISTest2;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class AisDriver {

    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {

        //1、出现一个job
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf);

        //2、指定jar包
        job.setJarByClass(AisDriver.class);

        //3、设置map和reduce的关系
        job.setMapperClass(AisMapper.class);
        job.setReducerClass(AisReducer.class);

        //4、设置map的输入和输出
        job.setMapOutputKeyClass(LongWritable.class);
        job.setMapOutputValueClass(AisBean.class);

        //5、设置最终的输入和输出
        job.setOutputKeyClass(LongWritable.class);
        job.setOutputValueClass(AisBean.class);

        //6、指定输入输出路径
        FileInputFormat.setInputPaths(job,new Path("D:\\AAUser\\dic\\Files\\testFile\\aistest1.csv"));
        FileOutputFormat.setOutputPath(job,new Path("D:\\AAUser\\dic\\Files\\testFile1"));

        //7、提交job
        boolean result = job.waitForCompletion(true);
        System.exit(result ? 0:1);
    }

}
